/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UICommand;
import javax.faces.component.UIForm;

/**
 *
 * @author Sanjay
 */
@ManagedBean(name="todoController")
@SessionScoped
public class ToDoController {

    private List<ToDo> todos;
   private ToDo toDo;
    private UIForm form;
    private UIForm tableForm;
    private UICommand addCommand;
    

    public ToDoController() {
        todos = new ArrayList<ToDo>();
        todos.add(new ToDo("Learn JSF", "Finish jsf framework", "2012-06-01", "2012-06-31", "12:00", "2012-06-01"));
        todos.add(new ToDo("Learn JSF", "Finish jsf framework", "2012-06-01", "2012-06-31", "12:00", "2012-06-01"));
        todos.add(new ToDo("Learn JSF", "Finish jsf framework", "2012-06-01", "2012-06-31", "12:00", "2012-06-01"));
        todos.add(new ToDo("Learn JSF", "Finish jsf framework", "2012-06-01", "2012-06-31", "12:00", "2012-06-01"));
    }

    public String save() {
       
        todos.add(toDo);
       return null;
        
    }

    public String cancel() {
        toDo = null;
        return null;
    }

    public String delete(ToDo todo) {
        todos.remove(todo);
        return null;
    }

    public List<ToDo> getToDos() {
        return todos;
    }

    public void setToDos(List<ToDo> todos) {
        this.todos= todos;
    }
    
    public ToDo getToDo(){
      return toDo;
    }
    
    public void setToDo(ToDo todo){
      this.toDo= todo;
    }

    public UICommand getAddCommand() {
        return addCommand;
    }

    public void setAddCommand(UICommand addCommand) {
        this.addCommand = addCommand;
    }

    public UIForm getForm() {
        return form;
    }

    public void setForm(UIForm form) {
        this.form = form;
    }

    public UIForm getTableForm() {
        return tableForm;
    }

    public void setTableForm(UIForm tableForm) {
        this.tableForm = tableForm;
    }
    
  
    
    
}
